package com.ykht.proj.coupon.utils;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ykht.proj.common.security.util.SecurityUtils;
import com.ykht.proj.coupon.Enum.WorkStateEnum;
import com.ykht.proj.coupon.entity.FxWaiterExt;
import com.ykht.proj.coupon.service.FxWaiterExtService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;


/**
 * 常用的方法Api
 */
@Component
@Data
public class UtilsApi {

	@Resource
	private FxWaiterExtService fxWaiterExtService1;
	private static FxWaiterExtService fxWaiterExtService;

	@PostConstruct
	public void init() {
		fxWaiterExtService = fxWaiterExtService1;
	}

	/**
	 * 获取当前登录人 服务员ID集合
	 *
	 * @return
	 */
	public static List<Long> getWaiterIdList() {
		return fxWaiterExtService.getWaiterIdList();
	}

	/**
	 * 获取现在的服务员信息
	 *
	 * @return
	 */
	public static FxWaiterExt getWaiterId() {
		FxWaiterExt waiterExt = new FxWaiterExt().selectOne((Wrappers.lambdaQuery(FxWaiterExt.class)
				.eq(FxWaiterExt::getLoginId, SecurityUtils.getUserId())
				.eq(FxWaiterExt::getWorkState, WorkStateEnum.WORK_STATE_1.getValue()).eq(FxWaiterExt::getDelFlag, 0)));
		return waiterExt;
	}


}
